<!--
  - Copyright 2011 Angel Sanadinov
  -
  - This file is part of VBox WMI.
  -
  - VBox WMI is free software: you can redistribute it and/or modify
  - it under the terms of the GNU General Public License as published by
  - the Free Software Foundation, either version 3 of the License, or
  - (at your option) any later version.
  -
  - VBox WMI is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  - GNU General Public License for more details.
  -
  - You should have received a copy of the GNU General Public License
  - along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
  -->

<%@tag import="Beans.Responses.DataRetrievalComponents.MachineSnapshotDataComponent" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="jstlc" %>
<%@taglib uri="/WEB-INF/tlds/pagePrintingTags.tld" prefix="p" %>
<%@tag description="Prints snapshot(s) data." pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>

<%-- Attributes --%>
<%@attribute name="snapshot" required="true" description="Machine snapshot data object."
             rtexprvalue="true" type="MachineSnapshotDataComponent"%>

<%@attribute name="rootLevelString" required="true" 
             description="A string to be used as a snapshots root when displaying the data."
             rtexprvalue="true" type="java.lang.String"%>

<%@attribute name="subLevelString" required="true"
             description="A string to be used as a sublevel to the root string."
             rtexprvalue="true" type="java.lang.String"%>
<%-- End of Attributes --%>

<%-- Page Body Content --%>
<jstlc:choose>
    <jstlc:when test="${snapshot != null}">
        ${rootLevelString}${subLevelString} ${snapshot.currentSnapshot ? "*" : ""} ${snapshot.name} - ${snapshot.description} |
        <a class="operationsLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('snapshotDataTable${snapshot.snapshotId}');">View</a>
        <a class="operationsLink" href="manage_machine.jsp?action=3&amp;id=${snapshot.machineId}&amp;operation=3&amp;snapshotId=${snapshot.snapshotId}">Restore</a>
        <a class="operationsLink" href="manage_machine.jsp?action=3&amp;id=${snapshot.machineId}&amp;operation=4&amp;snapshotId=${snapshot.snapshotId}"
           onclick="return resourceRemovalVerification('${snapshot.name}', this);">Remove</a><br>

        <form id="formModifySnapshot" action="manage_machine.jsp?action=3&amp;id=${snapshot.machineId}&amp;operation=2" method="post">
        <table id="snapshotDataTable${snapshot.snapshotId}" class="resourceDataTable">
            <tr><td><input type="hidden" name="modif.snapshot.snapshotId" value="${snapshot.snapshotId}"></td></tr>
            <tr><td>Machine ID:</td><td>${snapshot.machineId}</td></tr>
            <tr><td>Snapshot ID:</td><td>${snapshot.snapshotId}</td></tr>
            <tr><td>Snapshot Name:</td><td><input type="text" name="modify.snapshot.name" value="${snapshot.name}"></td></tr>
            <tr><td>Creation Date:</td><td>${snapshot.timeStamp}</td></tr>
            <tr><td>Description:</td><td><input type="text" name="modify.snapshot.description" value="${snapshot.description}"></td></tr>
            <tr><td>Online Snapshot:</td><td>${snapshot.online}</td></tr>
            <tr><td>Current Snapshot:</td><td>${snapshot.currentSnapshot}</td></tr>
            <tr><td>Parent ID:</td><td>${snapshot.parentId}</td></tr>
            <tr><td><input type="submit" value="Modify"></td></tr>
        </table>
        </form>

        <jstlc:forEach var="child" items="${snapshot.children}">
            <p:printSnapshot snapshot="${child}" rootLevelString="${rootLevelString}${subLevelString}" subLevelString="${subLevelString}"/>
        </jstlc:forEach>
    </jstlc:when>

    <jstlc:otherwise>
        ${rootLevelString} N/A
    </jstlc:otherwise>
</jstlc:choose>
<%-- End of Page Body Content --%>